// JavaScript Document
// this globals file is configured for US History I 

var g_course_title = "United States History";
var g_centerLatitude = 39;
var g_centerLongitude = -95;
var g_startZoom = 4;
var g_defaultZoom = 4;
var g_category = "";
var g_section = "";
var g_courseid = "us_hist_may08";

var map;

var markers= new Array();

// section and module codes 
// sections are 1-4 = q,b,b,9
// modules are 1-5 = 2,6,h,2,7
g_sec1_module1 = "Q2";
g_sec1_module2 = "Q6";
g_sec1_module2 = "Qh";


// Display error messages in a dialog box, but never more than 3

window.onerror = function(msg, url, line) {
    if (onerror.num++ < onerror.max) {
        alert("ERROR: " + msg + "\n" + url + ":" + line);
        return true;
    }
}
onerror.max = 3;
onerror.num = 0;



///////////////////////////////////////////////////////////////////////////////////
// return the params from the HTML query string
///////////////////////////////////////////////////////////////////////////////////
function getArgs( ) {
	var args = new Object( );
	var query = location.search.substring(1);
	var pairs = query.split("&");
	if (pairs.length == 0 ) {
		return 0;
	}
	for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		value = decodeURIComponent(value);
		args[argname] = value;
	}
	return args;
}



//////////////////////////////////////////////////////////////////////////////////////
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

//////////////////////////////////////////////////////////////////////////////////////
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//////////////////////////////////////////////////////////////////////////////////////
function eraseCookie(name) {
	createCookie(name,"",-1);
}
